package com.beehoo.dcportal.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.beehoo.dcportal.common.base.BaseException;
import com.beehoo.dcportal.dao.IBusinessDao;
import com.beehoo.dcportal.model.BusinessBean;
import com.beehoo.dcportal.service.IBusinessServ;
import com.beehoo.dcportal.utils.CommonUtils;

public class BusinessServImpl implements IBusinessServ {

	private IBusinessDao businessDao;

	public void setBusinessDao(IBusinessDao businessDao) {
		this.businessDao = businessDao;
	}

	@Override
	public List<BusinessBean> queryBusiness(String streetId, String condition,
			int pageNo, int pageRows) throws BaseException {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("streetId", streetId);
		if(!CommonUtils.nvlToString(condition).equals(""))
			paramMap.put("condition", "%"+condition+"%");
		paramMap.put("offset", (pageNo-1)*pageRows);
		paramMap.put("pageRows", pageRows);
		return businessDao.queryBusiness(paramMap);
	}

	@Override
	public int queryBusinessCount(String streetId, String condition) throws BaseException {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("streetId", streetId);
		if(!CommonUtils.nvlToString(condition).equals(""))
			paramMap.put("condition", "%"+condition+"%");
		return businessDao.queryBusinessCount(paramMap);
	}

}
